<?php

require_once("../../controllers/init.php");
require_once($FILE_SYSTEM_ROOT."/controllers/authentication.php");

// get all the people first!

$peopleGroups = array();

if(isset($_POST['people']))
{
//	print_r($_POST['people']);
	$peopleGroups = $_POST['people'];
}

$people = new PeopleResultSet($peopleGroups);

$peopleArray = $people->getPeople();

foreach ($peopleArray as $person)
{
	print "<div class=\"people-table\" id=\"people-table-".$person->getID()."\">";
	print "<div class=\"people-table-name\">".$person->getFirstName()." ".$person->getSurname()."</div>";
	
	print "<div class=\"people-table-emails\">";
	foreach ($person->getEmails() as $email)
	{
		print $email."<br>";
	}
	print "</div>";
	
	print "<div class=\"people-table-groups\">";
	foreach ($person->getGroups() as $group)
	{
		print $GROUPS[$group]."<br>";
	}
	print "</div>";
	
	print "<div class=\"people-table-telephones\">";
	foreach ($person->getTelephones() as $telephone)
	{
		print $telephone."<br>";
	}
	print "</div>";
	
	print "<div class=\"people-table-addresses\">";
	foreach ($person->getAddresses() as $address)
	{
		print "<div id=\"people-table-address-".$address->getAddressID()."\" class=\"people-table-address\">".$address->getAddress1()."</div>\n";
		print "<div class=\"people-table-fulladdress\" id=\"people-table-fulladdress-id\">\n";
		if($address->getAddress1()!="") print $address->getAddress1()."<br>\n";
		if($address->getAddress2()!="") print $address->getAddress2()."<br>\n";
		if($address->getAddress3()!="") print $address->getAddress3()."<br>\n";
		if($address->getAddress4()!="") print $address->getAddress4()."<br>\n";
		if($address->getPostcode()!="") print $address->getPostcode()."<br>\n";
		if($address->getCounty()!="")   print $address->getCounty()."<br>\n";
		if($address->getCountry()!="")  print $address->getCountry()."<br>\n";
		print "</div>\n";
	}
	print "</div>";
	
	print "</div>";
}

?>

